#include <algorithm>
#include <iostream>
using namespace std;

const int kMaxN = 2e5 + 10;

int a[kMaxN];
bool vis[kMaxN];

bool IsPermutation(int n) {
  for (int i = 0; i < n; i++) {
    vis[a[i]] = true;
  }
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      return false;
    }
  }
  return true;
}

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int T;

  for (cin >> T; T; T--) {
    int n, k;
    cin >> n >> k;
    fill(vis, vis + n + 1, false);
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }

    int ans[3];

    if (IsPermutation(n)) {
      ans[0] = a[n - 3];
      ans[1] = a[n - 2];
      ans[2] = a[n - 1];
    } else {
      ans[2] = a[n - 1];
      for (ans[0] = 1; vis[ans[0]] == true; ans[0]++);
      for (ans[1] = 1; ans[1] == ans[0] || ans[1] == ans[2]; ans[1]++);
    }
    for (int i = 0; i < k; i++) {
      cout << ans[i % 3] << " ";
    }
    cout << "\n";
  }
  return 0;
}